/**
* Created by wust on 2019-12-27 15:53:44.
*/
<template>
  <el-form ref="formModel" :model="formModel" :rules="rules" label-width="120px" style="width:70%;" @submit.native.prevent>
    <el-form-item label="xxx">
      <el-input
        v-model="formModel.xxx" :disabled="true">
      </el-input>
    </el-form-item>
    <el-form-item style="text-align: left;">
      <el-button type="primary" @click="onSubmit('formModel')">提交</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'account-update',
  props: ['selectedModel'],
  data () {
    return {
      formModel: {
        id: '',
        xxx: ''
      },
      rules: {
        xxx: [{required: true, message: '请输入XXX', trigger: 'blur'}]
      }
    }
  },
  created: function () {
    this.formModel = this.selectedModel
  },
  methods: {
    onSubmit: function (formData) {
      this.$refs[formData].validate((valid) => {
        if (!valid) {
        } else {
          Vue.$ajax({
            method: 'put',
            url: Vue.$adminServerURL + '/web/v1/AccountController',
            data: this.formModel
          }).then(res => {
            if (res.data.flag !== 'SUCCESS') {
              if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
                this.$message({
                  message: res.data.message,
                  type: 'warning'
                })
              }
            } else {
              this.$message({
                message: res.data.message,
                type: 'success'
              })
            }
          })
        }
      })
    }
  }
}
</script>
